import matplotlib.pyplot as plt
plt.rcParams['font.sans-serif'] = ['SimHei']  # 解决中文乱码问题
plt.rcParams['axes.unicode_minus'] = False  # 解决正负号乱码问题
# days = ['01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12','13','14','15']  # 准备月份信息
# temps = [-3, 0, 8, 15, 22, 26, 28, 27, 21, 14, 5, -1]  # 准备温度数据
# max_temps = [29,30,31,32,33,34,31,30,29,30,32,33,31,30,29]  # 准备平均最高温度数据
# min_temps = [22,23,24,25,24,25,24,23,22,23,24,25,24,23,22]  # 准备平均最低温度数据
# plt.figure(figsize=(16, 4), dpi=150)  # 定义画布尺寸和分辨率
# plt.grid(linestyle=":", alpha=0.5)  # 添加画布网格
# for i, txt in enumerate(max_temps):
#     plt.annotate(f'{txt}℃', (days[i], max_temps[i]), textcoords="offset points", color="green", xytext=(0, -15), ha='center')
# for i, txt in enumerate(min_temps):
#     plt.annotate(f'{txt}℃', (days[i], min_temps[i]), textcoords="offset points", color="black", xytext=(0, -15), ha='center')
# plt.xlabel("日份")  # 添加x轴标签
# plt.ylabel("温度（单位：℃）")  # 添加y轴标签
# plt.title("清远市未来15天的最低温和最高温")  # 添加图表标题
# plt.plot(days, max_temps, color="c", label="平均最高温度",marker='o')  # 绘制平均最高温度折线图
# plt.plot(days, min_temps, color="m", label="平均最低温度",marker='o')  # 绘制平均最低温度折线图
# plt.legend()  # 绘制图例，需要先在绘制曲线的同时，添加曲线的label标签



# # 2.准备实验数据
# name_list = ['01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12', '13', '14','15']
# calorie_list = [3.2,5.1,0.0,0.5,8.7,15.4,12.3,2.1,0.0,1.2,6.8,20.1,7.5,3.0,.02]
# # 3.定义画布尺寸和分辨率
# plt.figure(ﬁgsize=(12, 6), dpi=150)
# # 4.绘制柱状图
# x = range(len(name_list))
# plt.xticks(x, name_list)
# plt.bar(x, calorie_list, width=0.4, color=['#ffaa00' if i>300 else '#40c000' for i in calorie_list])
# # 5.柱状图修饰
# # 添加提示信息
# plt.title("未来15天降水量柱状图")  # 添加标题
# plt.xlabel("天数")  # 添加x轴标签
# plt.ylabel("降水量/ml")  # 添加y轴标签 # 添加网格
# plt.grid(linestyle="--", alpha=0.2)
# plt.figure(figsize=(12, 6), dpi=150)
# x = range(len(name_list))
# plt.xticks(x, name_list)  # 解决中文刻度展示问题
# plt.bar(x, calorie_list, width=0.4, color=['#ffaa00' if i>300 else '#40c000' for i in calorie_list])



# # 2.准备数据
# item_name = ["王者荣耀", "原神", "和平精英", "金铲铲之战", "第五人格", "开心消消乐","贪吃蛇大作战", "其他"]  # 品牌名
# item_quantity = [35, 20, 12, 10, 8, 6, 5, 4]  # 各品牌手机全球销量（单位：百万）
# # 3.创建画布
# plt.figure(figsize=(10, 5), dpi=150)
# # 4.绘制饼图
# explode = (0, 0, 0, 0, 0, 0, 0, 0.1)  # 突出展示【其他】手机部分
# # 5.修饰图像
# plt.title("2025年国内热门游戏排行饼状图", fontsize=16)  # 添加标题
# plt.axis("equal")  # 修正饼图的展示效果
# plt.legend()
# plt.pie(item_quantity, labels=item_name, autopct="%.2f%%", explode=explode)


# # 2.准备实验数据，x对应房屋面积，y对应房屋价格
# x = [52.71, 60.77, 83.35, 77.49, 32.9, 76.18, 63.48, 77.41, 86.75, 80.69, 91.23, 81.16, 85.13, 65.85, 37.11, 77.83, 62.12,41.28, 66.9, 86.95, 75.1, 43.08, 59.1, 97.66, 50.06, 107.09, 65.49, 98.2, 88.97, 111.42, 86.95, 73, 108.51, 28.79, 53.79, 89.64, 107.6, 75.66, 97.03, 90.91, 84.65, 32.06, 35.56, 89.19, 23.06, 50, 39.5, 50.96, 44.81, 76.9]
# y = [358, 420, 588, 588, 295, 499, 815, 535, 698, 660, 595, 530, 605, 465, 285, 575, 480, 276, 451, 585, 661, 250, 405, 575, 700, 758, 470, 618, 830, 850, 575, 478, 830, 290, 660, 670, 880, 620, 735, 630, 618, 375, 240, 660, 160, 350, 368, 350, 380, 490]
# # 3.创建画布
# plt.figure(figsize=(12, 6), dpi=150)
# # 4.绘制图像
# plt.scatter(x, y)
# # 5.修饰图像
# plt.title("深圳市福田区二手房面积与售价关系图", fontsize=16)  # 添加标题
# plt.xlabel("房屋面积（单位：平方米）")  # 添加x轴标签
# plt.ylabel("房屋售价（单位：万）")  # 添加y轴标签
# plt.grid(linestyle="--", alpha=0.2)  # 添加网格
# plt.xticks(range(20, 120, 5))  # 重设x轴刻度

plt.savefig('temp.png')
plt.show()